'use strict';

/**
 * Config for the router
 */
angular.module('app')
    .run(
        ['$rootScope', '$state', '$stateParams',
            function($rootScope, $state, $stateParams) {
                $rootScope.$state = $state;
                $rootScope.$stateParams = $stateParams;
            }
        ]
    )
    .config(
        ['$stateProvider', '$urlRouterProvider',
            function($stateProvider, $urlRouterProvider) {
                $urlRouterProvider
                    .otherwise('/access/signin');
                $stateProvider
                    .state('app', {
                        abstract: true,
                        url: '/app',
                        templateUrl: 'views/app.html'
                    })
                    .state('nav', {
                        url: '/nav',
                        // template: '<div ui-view class="fade-in-right-big smooth"></div>'
                        templateUrl: 'views/nav/auditPage.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['css/directives/tabset.css?v3&t=20170601']);
                                }
                            ]
                        }
                    })
                    .state('nav.widget', {
                        url: '/widget',
                        templateUrl: 'views/nav/widget.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['js/controllers/nav/widget.js?v3&t=20170601']);
                                }
                            ]
                        }
                    })

                .state('nav.personal', {
                    url: '/personal',
                    templateUrl: 'views/nav/personal.html',
                    resolve: {
                        deps: ['uiLoad',
                            '$ocLazyLoad',
                            function(uiLoad, $ocLazyLoad) {
                                return $ocLazyLoad.load('ui.select').then(
                                    function() {
                                        return $ocLazyLoad.load('angularFileUpload').then(
                                            function() {
                                                return $ocLazyLoad.load('js/controllers/nav/personal.js?v3&t=20170601');
                                            });
                                    }
                                );
                            }
                        ]
                    }
                })

                .state('nav.company', {
                    url: '/company',
                    templateUrl: 'views/nav/company.html',
                    resolve: {
                        deps: ['uiLoad',
                            '$ocLazyLoad',
                            function(uiLoad, $ocLazyLoad) {
                                return $ocLazyLoad.load('ui.select').then(
                                    function() {
                                        return $ocLazyLoad.load('angularFileUpload').then(
                                            function() {
                                                return $ocLazyLoad.load('js/controllers/nav/company.js?v3&t=20170601');
                                            });
                                    }
                                );
                            }
                        ]
                    }
                })

                .state('nav.personalLandlord', {
                    url: '/personalLandlord',
                    templateUrl: 'views/nav/personalLandlord.html',
                    resolve: {
                        deps: ['uiLoad',
                            '$ocLazyLoad',
                            function(uiLoad, $ocLazyLoad) {
                                return $ocLazyLoad.load('ui.select').then(
                                    function() {
                                        return $ocLazyLoad.load('angularFileUpload').then(
                                            function() {
                                                return $ocLazyLoad.load('js/controllers/nav/personalLandlord.js?v3&t=20170601');
                                            });
                                    }
                                );
                            }
                        ]
                    }
                })

                .state('app.houseOwner', {
                        url: '/houseOwner',
                        template: '<div ui-view></div>'
                    })
                    .state('app.fundManage', {
                        url: '/fundManage',
                        template: '<div ui-view></div>'
                    })
                    .state('app.houseOwner.modelList', {
                        url: '/modelList',
                        templateUrl: 'views/houseOwner/modelList.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/houseOwner/modelList.js?v3&t=20170601']);
                                    });
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.list', {
                        url: '/list',
                        templateUrl: 'views/houseOwner/list.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/houseOwner/list.js?v3&t=20170601']);
                                    });
                                }
                            ]
                        }
                    })

                .state('app.houseOwner.addHouse', {
                        url: '/addHouse',
                        templateUrl: 'views/houseOwner/addHouse.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    return $ocLazyLoad.load('js/controllers/houseOwner/addHouse.js?v3&t=20170601');
                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.housePicsTemplet', {
                        url: '/housePicsTemplet',
                        templateUrl: 'views/houseOwner/housePicsTemplet.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    return $ocLazyLoad.load('js/controllers/houseOwner/housePicsTemplet.js?v3&t=20170601');
                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.editHousePicsTemplet', {
                        url: '/editHousePicsTemplet/',
                        templateUrl: 'views/houseOwner/editHousePicsTemplet.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    return $ocLazyLoad.load('js/controllers/houseOwner/editHousePicsTemplet.js?v3&t=20170601');
                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.batchImport', {
                        url: '/batchImport/',
                        templateUrl: 'views/houseOwner/batchImport.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    return $ocLazyLoad.load('js/controllers/houseOwner/batchImport.js?v3&t=20170601');
                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.createContract', {
                        url: '/createContract/:id',
                        templateUrl: 'views/houseOwner/createContract.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('js/controllers/houseOwner/createContract.js?v3&t=20170601');
                                        }
                                    );
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.editHouse', {
                        url: '/editHouse/:id',
                        templateUrl: 'views/houseOwner/editHouse.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    return $ocLazyLoad.load('js/controllers/houseOwner/editHouse.js?v3&t=20170601');
                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })

                .state('app.houseOwner.viewHouse', {
                        url: '/viewHouse/:id',
                        templateUrl: 'views/houseOwner/viewHouse.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    return $ocLazyLoad.load('js/controllers/houseOwner/viewHouse.js?v3&t=20170601');
                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.loanList', {
                        url: '/loanList',
                        // controller: 'houseOwnerLoanListCtl',
                        templateUrl: 'views/houseOwner/loanList.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return $ocLazyLoad.load('js/controllers/houseOwner/loanList.js?v3&t=20170601');
                                    });
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.loanRepayDetail', {
                        url: '/loanRepayDetail:orderId',
                        templateUrl: 'views/houseOwner/loanRepayDetail.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/houseOwner/loanRepayDetail.js?v3&t=20170601']);
                                    });
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.rentRepayDetail', {
                        url: '/rentRepayDetail:orderId',
                        templateUrl: 'views/houseOwner/rentRepayDetail.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/houseOwner/rentRepayDetail.js?v3&t=20170601']);
                                    });
                                }
                            ]
                        }
                    })

                .state('app.houseOwner.changePsw', {
                        url: '/changePsw',
                        templateUrl: 'views/houseOwner/changePsw.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return $ocLazyLoad.load(['js/controllers/houseOwner/changePsw.js?v3&t=20170601']);
                                    });
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.goCapitalPsw', {
                        url: '/capitalPsw',
                        templateUrl: 'views/houseOwner/capitalPsw.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return $ocLazyLoad.load(['js/controllers/houseOwner/capitalPsw.js?v3&t=20170601']);
                                    });
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.forgetLoginPsw', {
                        url: '/forgetLoginPsw',
                        templateUrl: 'views/houseOwner/forgetLoginPsw.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return $ocLazyLoad.load(['js/controllers/houseOwner/forgetLoginPsw.js?v3&t=20170601']);
                                    });
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.forgetCapitalPsw', {
                        url: '/forgetCapitalPsw',
                        templateUrl: 'views/houseOwner/forgetCapitalPsw.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return $ocLazyLoad.load(['js/controllers/houseOwner/forgetCapitalPsw.js?v3&t=20170601']);
                                    });
                                }
                            ]
                        }
                    })
                    .state('access', {
                        url: '/access',
                        template: '<div ui-view class="fade-in-right-big smooth"></div>'
                    })
                    .state('access.signin', {
                        url: '/signin',
                        templateUrl: 'views/page_signin.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['js/controllers/signin.js?v3&t=20170601']);
                                }
                            ]
                        }
                    })
                    .state('access.register', {
                        url: '/register',
                        templateUrl: 'views/page_register.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['js/controllers/register.js?v3&t=20170601']);
                                }
                            ]
                        }
                    })
                    .state('access.forgetPossWord', {
                        url: '/forgetPossWord',
                        templateUrl: 'views/page_forgetPossWord.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['js/controllers/forgetPossWord.js?v3&t=20170601']);
                                }
                            ]
                        }
                    })
                    .state('access.signout', {
                        url: '/signout',
                        templateUrl: 'views/page_signout.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['js/controllers/signout.js?v3&t=20170601']);
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.uploadtest', {
                        url: '/uploadtest',
                        templateUrl: 'js/module/upload-direct/uploadtest.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('angularFileUpload').then(
                                        function() {
                                            return $ocLazyLoad.load('js/module/upload-direct/uploadtest.js?v3&t=20170601');
                                        }
                                    );
                                }
                            ]
                        }
                    })
                    .state('app.houseOwner.addtest', {
                        url: '/addtest',
                        templateUrl: 'js/module/upload-direct/addtest.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    return $ocLazyLoad.load('js/module/upload-direct/addtest.js?v3&t=20170601');
                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })
            }
        ]
    );